package cae.gui.conf;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.netbeans.validation.api.ui.ValidationPanel;

import cae.logic.util.CaeClipConfiguration;

public class CaeConexion extends JPanel
{

	private static final long serialVersionUID = 1L;
	private static CaeClipConfiguration conf = CaeClipConfiguration.getInstance();

	public CaeConexion(ValidationPanel pnl)
	{
		setLayout( new GridBagLayout() );
		GridBagConstraints gc = new GridBagConstraints();
		gc.insets = new Insets(2,2,2,2);
		gc.fill = GridBagConstraints.BOTH;
		gc.weightx = 0;
		gc.weighty = 0;
		Dimension d = new Dimension(200, 20);


		// CHAT
		gc.gridx = 0;
		gc.gridy = 0;
		add(new JLabel("Chat Port: "), gc);
		int chatPort = conf.getIProp(CaeClipConfiguration.PORT_CHAT);
		JTextField field = new JTextField(chatPort+"");
		field.setPreferredSize(d);
		field.setMaximumSize(d);
		field.setMinimumSize(d);
		field.setName ("Chat Port");
		//Validator<Document> dd = Validators.forDocument(true, Validators.REQUIRE_NON_EMPTY_STRING, Validators.numberRange(0, 65535), Validators.REQUIRE_VALID_INTEGER);
		//pnl.getValidationGroup().add (field, dd);
		gc.gridx = 1;
		gc.gridy = 0;
		add(field, gc);
		
		gc.gridx = 0;
		gc.gridy = 1;
		add(new JLabel("Popup Port: "), gc);
		int popupPort = conf.getIProp(CaeClipConfiguration.PORT);
		JTextField popupPortField = new JTextField(popupPort+"");
		popupPortField.setName ("Popup Port");
		//Validator<Document> dd2 = Validators.forDocument(true, Validators.REQUIRE_NON_EMPTY_STRING, Validators.numberRange(0, 65535), Validators.REQUIRE_VALID_INTEGER);
		//pnl.getValidationGroup().add (popupPortField, dd2);
		gc.gridx = 1;
		gc.gridy = 1;
		add(popupPortField, gc);
	}
}
